import { Component } from '@angular/core';
import { NavController, AlertController } from 'ionic-angular';
import { AuthService } from '../../../../providers/auth-service';


@Component({
  selector: 'page-my-modify',
  templateUrl: 'modify.html'
})

export class MyModifyPage {
  user:any
  constructor(public navCtrl: NavController,
   private auth: AuthService,
   private alertCtrl: AlertController
   ) {
    this.user =  auth.getUserInfo().user
  }
  public modifyMyInfo() {
   this.auth.modifyUser(this.user).then(() => {
       this.showPopup("修改成功", "即将返回");
    })
  }
  showPopup(title, text) {
    let alert = this.alertCtrl.create({
      title: title,
      subTitle: text,
      buttons: [
       {
         text: 'OK',
         handler: data => {
           this.navCtrl.popToRoot();
         }
       }
     ]
    });
    alert.present();
  }
}
